package icu.bughub.app.app.viewmodel

import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel

class TaskViewModel : ViewModel() {


    var taskDate by mutableStateOf("学习周期:2025.01.01-2026.01.01")  // 学习周期
        private set

    var totalPointOfYear by mutableStateOf(13500)  // 学年总积分
        private set

    //学年积分
    var pointOfYear by mutableStateOf(10000)
        private set

    //计算学年积分进度
    // 学年积分进度 = 220f * 当前积分 / 学年总积分

    var pointOfYearPercent by mutableStateOf(0f)
        private set

    //更新学年积分进度
    fun updatePointPercent() {
        if (pointOfYear > totalPointOfYear) {
            pointOfYear = totalPointOfYear
        }
        pointOfYearPercent = 220f * pointOfYear / totalPointOfYear
    }

    //一周积分情况
    var pointOfWeek by mutableStateOf(listOf<Float>(0.0f, 2.0f, 6.0f, 9.5f, 10f, 15f, 5f))
        private set

    //日期
    var weeks = listOf<String>("06.01", "06.02", "06.03", "06.04", "06.05", "06.07", "今日")
        private set

    //今日积分
    var todayPoint by mutableStateOf(13)
        private set

    //更新今日积分
    fun updateTodayPoint(point: Int) {
        todayPoint = point
        updateTips() // 更新今日提醒文字
    }

    //今日提醒文字
    var tips by mutableStateOf("今日获得${todayPoint}积分，快去完成下面任务吧")
        private set

    //更新今日提醒文字
    fun updateTips() {
        when {
            todayPoint == 0 -> {
                tips = "今日获得0积分，快去完成下面任务吧"
            }

            todayPoint > 0 && todayPoint < 15 -> {
                tips = "今日获得${todayPoint}积分，快去完成下面任务吧"
            }

            else -> {
                tips = "今日获得${todayPoint}积分，已经完成所有任务"

            }
        }

    }

}